// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import axios from 'axios'
import VueCookies from 'vue-cookies'
import common from './common/js/common.js'
import './common/css/main.css'
import MintUI from 'mint-ui'
import store from './store'
import 'mint-ui/lib/style.css'
import 'font-awesome/css/font-awesome.min.css'

Vue.use(common)
Vue.use(VueCookies)
Vue.use(MintUI)


Vue.prototype.$ajax= axios
Vue.config.productionTip = false

router.beforeEach((to,from,next)=>{
    let token = $cookies.get('token')
    if(to.meta.requireAuth){
        if(token != '' && token != null){
            next()
        }else{
            next({path:'/mobile'})
        }
    }else{
        let token = $cookies.get('token')
        if(token != '' && token != null){
            next({path:'/index'})
        }else{
            next()
        }
    }
})

/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    store,
    components: { App },
    template: '<App/>'
})
